package cn.hnu.jpa.jpaExample.bidirectional;

import java.io.Serializable;

import javax.persistence.CascadeType;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.OneToOne;

@Entity
public class Student implements Serializable{

	/**
	 * 双向关联 person and address
	 */
	private static final long serialVersionUID = 1L;

	private Integer id;
	
	private StuAddress addr;
	
	private String name;

	
	
	public Student() {
	}

	public Student(StuAddress addr, String name) {
		super();
		this.addr = addr;
		this.name = name;
	}

	@Id @GeneratedValue(strategy = GenerationType.AUTO)
	public Integer getId() {
		return id;
	}

	public void setId(Integer id) {
		this.id = id;
	}

	@OneToOne(cascade = {CascadeType.ALL},fetch = FetchType.LAZY)
	@JoinColumn(name = "addr_id")
	public StuAddress getAddr() {
		return addr;
	}

	public void setAddr(StuAddress addr) {
		this.addr = addr;
	}

	public String getName() {
		return name;
	}

	public void setName(String name) {
		this.name = name;
	}
	
	
}
